package world.ztomorrow.user.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import world.ztomorrow.common.dto.RestResp;
import world.ztomorrow.user.dto.resp.ImgVerifyCodeRespDto;
import world.ztomorrow.user.service.ResourceService;

import java.io.IOException;

@RestController
@RequiredArgsConstructor
@RequestMapping("/front/resource")
public class ResourceController {

    private final ResourceService resourceService;

    @GetMapping("/img_verify_code")
    public RestResp<ImgVerifyCodeRespDto> getImgVerifyCode() throws IOException {
        return resourceService.getImgVerifyCode();
    }

    /**
     * 图片上传接口
     */
    @PostMapping("/image")
    RestResp<String> uploadImage(@RequestParam("file") MultipartFile file) throws IOException {
        return resourceService.uploadImage(file);
    }
}
